package router

import (
	"gitee.com/tang_q/gin-vue3-admin-api/api"
	"github.com/gin-gonic/gin"
)

func UserRoutes() {
	RegisterRoute(func(rgPublic *gin.RouterGroup, rgAuth *gin.RouterGroup) {
		userApi := api.NewUserApi()
		rgPublicUser := rgPublic.Group("user").Use(func() gin.HandlerFunc {
			return func(ctx *gin.Context) {
				// 这里可以添加user公开的路由中间件
			}
		}())
		{
			rgPublicUser.POST("/login", userApi.Login)
			rgPublicUser.POST("/logout", userApi.Logout)
			rgPublicUser.GET("/info", userApi.GetUsersInfo)
			rgPublicUser.GET("/center", userApi.GetUserPInfo)
			rgPublicUser.POST("/updateInfo", userApi.UpdateInfo)
			rgPublicUser.POST("/upload/avatar", userApi.UploadAvatar)
			rgPublicUser.GET("/avatar/:filename", userApi.GetUserAvatar)
			rgPublicUser.GET("/updateAvatar/:filename", userApi.UpdateAvatar)
		}

		rgAuthUser := rgAuth.Group("user")
		{
			rgAuthUser.POST("/getUserList", userApi.GetUsersList)
			rgAuthUser.POST("/createUser", userApi.CreateUser)
			rgAuthUser.POST("/updateUser", userApi.UpdateUser)
			rgAuthUser.DELETE("/deleteUser", userApi.DeleteUser)
			rgAuthUser.DELETE("/deleteUsers", userApi.DeleteUsers)
		}
	})
}
